make formats only have one model
authorØyvind Kolås <ok@src.gnome.org>
Tue, 23 Aug 2005 07:40:54 +0000 (07:40 +0000)
committerØyvind Kolås <ok@src.gnome.org>
Tue, 23 Aug 2005 07:40:54 +0000 (07:40 +0000)
babl/babl-classes.h
babl/babl-fish.c

index d8342682fcb0d61c74c8ea77ee7af777ce01ebf9..727be57856779688d081329d25efc23941a4c1e7 100644 (file)
@@ -54,7 +54,9 @@ typedef void (*BablFuncPlanarBit) (int    src_bands,
 
 typedef enum {
   BABL_INSTANCE = BABL_MAGIC,
-  BABL_TYPE,                   
+  BABL_TYPE,
+  BABL_TYPE_INTEGER,
+  BABL_TYPE_FLOAT,
   BABL_SAMPLING,
   BABL_COMPONENT,
   BABL_MODEL,
@@ -77,6 +79,8 @@ typedef enum {
 #define BABL_CLASS_TYPE_IS_VALID(klass_type) \
     (  ((klass_type)>=BABL_INSTANCE ) && ((klass_type)<=BABL_SKY) ?1:0 )
 
+const char  *babl_class_name     (BablClassType klass);
+
 /* common header for any item inserted into database */
 typedef struct
 {
@@ -134,8 +138,26 @@ typedef struct
   BablConversion **to;    /*< NULL terminated list of conversions to class   */
   int              bits;  /*< number of bits used to represent the data type
                             (initially restricted to a multiple of 8) */
+  double           min_val;
+  double           max_val;
 } BablType;
 
+typedef struct
+{
+  BablType          type;
+  int               is_signed;
+  long              max;
+  long              min;
+} BablTypeInteger;
+
+typedef struct
+{
+  BablType type;
+  /* sign
+   * biased_exponent
+   * mantissa */
+} BablTypeFloat;
+
 typedef struct
 {
   BablInstance instance;
index 3be6b33d58cc6fc6f79647b860cd60ab167ed039..678af6a760db8436c7e17cba3fa55b7175b81795 100644 (file)
@@ -231,6 +231,9 @@ babl_fish_process (Babl *babl,
   Babl *imageB;
   Babl *imageC;
 
+  /* FIXME: assumptions made about memory requirements that 
+   * are not good
+   */
   fooA = babl_malloc(sizeof (double) * n * 4);
   fooB = babl_malloc(sizeof (double) * n * 4);
 
@@ -247,12 +250,10 @@ babl_fish_process (Babl *babl,
                 __FUNCTION__, babl_fish, source, destination, n);
       return -1;
     }
-  
-  babl->reference_fish.type_to_double->function.linear(
-          source,
-          fooA,
-          n*  BABL(babl->fish.source)->pixel_format.bands
-          );
+  babl_conversion_process (babl->reference_fish.type_to_double,
+                           source, fooA,
+                           n * BABL(babl->fish.source)->pixel_format.bands);
 
   /* calculate planar representation of fooA, and fooB */
 
@@ -260,35 +261,29 @@ babl_fish_process (Babl *babl,
   imageB = babl_image_new_from_linear (fooB, babl_model_id (BABL_RGBA));
   /* transform fooA into fooB fooB is rgba double */
 
-  babl->reference_fish.model_to_rgba->function.planar(
-          imageA->image.bands, 
-          imageA->image.data,
-          imageA->image.pitch,
-          imageB->image.bands, 
-          imageB->image.data,
-          imageB->image.pitch,
-          n);
+  babl_conversion_process (babl->reference_fish.model_to_rgba,
+                           imageA, imageB,
+                           n);
+  
   babl_free (imageA);
   babl_free (imageB);
 
   /* calculate planar representation of fooC */
   /* transform fooB into fooC fooC is ???? double */
 
-  imageB = babl_image_new_from_linear (fooB, babl_model_id (BABL_RGBA));
-  imageC = babl_image_new_from_linear (fooA, BABL(BABL((babl->fish.destination))->pixel_format.model));
-
-  babl->reference_fish.rgba_to_model->function.planar(
-          imageB->image.bands, 
-          imageB->image.data,
-          imageB->image.pitch,
-          imageC->image.bands, 
-          imageC->image.data,
-          imageC->image.pitch,
-          n);
+  imageB = babl_image_new_from_linear (
+              fooB, babl_model_id (BABL_RGBA));
+  imageC = babl_image_new_from_linear (
+              fooA, BABL(BABL((babl->fish.destination))->pixel_format.model));
 
+  babl_conversion_process (babl->reference_fish.rgba_to_model,
+                           imageB, imageC,
+                           n);
 
-  babl->reference_fish.double_to_type->function.linear(
-          fooA, destination, n * BABL(babl->fish.destination)->pixel_format.bands);
+  /* working directly on linear buffers */
+  babl_conversion_process (babl->reference_fish.double_to_type,
+                           fooA, destination,
+                           n * BABL(babl->fish.destination)->pixel_format.bands);
 
   babl_free (imageB);
   babl_free (imageC);